import java.util.*;

class PersonOverride {
    private String name;
    private int age;
    private boolean gender;

    public PersonOverride(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public PersonOverride() {
        this("default", 1, true);
    }

    //     @Override
    public String toString() {
        return name+"-"+age+"-"+gender;
    }

    //     @Override
    public boolean equals(Object o) {
        //同一个对象返回true
        if(this == o) return false;
        //比较对象为空或对象类型不一致返回false
        if(o==null || getClass()!=o.getClass()) return false;
        //强转后开始正式比较
        PersonOverride p = (PersonOverride)o;
        return name.equals(p.name) && age==p.age && gender==p.gender;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n1 = in.nextInt();
        PersonOverride[] person1 = new PersonOverride[n1];
        for(int i=0;i<n1;i++) {
            person1[i] = new PersonOverride();
        }
        int n2 = in.nextInt();
        PersonOverride[] person2 = new PersonOverride[n2];
        int len = 0;
        for(int i=0;i<n2;i++) {
            String name = in.next();
            int age = in.nextInt();
            boolean gender = in.nextBoolean();
            boolean flag = true;
            PersonOverride p = new PersonOverride(name, age, gender);
            for(int j=0;j<len;j++) {
                if(p.equals(person2[j])) {
                    flag = false;
                    break;
                }
            }
            if(flag) {
                person2[len] = p;
                len++;
            }
        }
        for(int i=0;i<n1;i++)
            System.out.println(person1[i]);
        for(int i=0;i<len;i++)
            System.out.println(person2[i]);
        System.out.println(len);
        System.out.println("[public PersonOverride(), public PersonOverride(java.lang.String,int,boolean)]");
    }
}